# 从框架中引入 标准模板 数据类型
from django.db import models


# 创建数据模型
class Users(models.Model):
    ## 属性 -- 字段 设置字段数据表类型，字符型models.CharField
    ## 数值型models.DecimalField()时间型models.DateTimField()
    username = models.CharField(max_length=32)
    userpwd = models.CharField(max_length=32)

class Goods(models.Model):
    goodsid = models.AutoField(primary_key=True)
    goodsname = models.CharField(max_length=32)
    goodsimg = models.CharField(max_length=64)
    goodsprice = models.DecimalField(max_digits=10, decimal_places=2)
    goodscount = models.DecimalField(max_digits=10, decimal_places=0)

class GoodsCars(models.Model):
    cid = models.AutoField(primary_key=True)
    # goodsid = models.DecimalField(max_digits=10, decimal_places=0)
    # 设置 商品 字段并且表示 和之前建立的数据模型Goods有关联
    good = models.ForeignKey('Goods', on_delete=models.CASCADE)
    buy_count = models.DecimalField(max_digits=10, decimal_places=0)
    uid = models.DecimalField(max_digits=10, decimal_places=0)
